from django.db import models
# Create your models here.
# 无须创建ID 系统会自动创建自增ID作为主键

# 系统菜单
class MenuModel(models.Model):
    
    name = models.CharField(max_length=50, verbose_name="菜单名称")
    pid = models.IntegerField(default=0, verbose_name="pid")
    order_num = models.IntegerField(default=0, verbose_name="排序")
    path = models.CharField(max_length=200, verbose_name="路径")
    component = models.CharField(max_length=200, verbose_name="组件")
    query = models.CharField(max_length=200, verbose_name="参数")

    links = models.IntegerField(default=0, verbose_name="是否外链")
    cache = models.IntegerField(default=0, verbose_name="是否缓存")
    visible = models.IntegerField(default=0, verbose_name="是否可见")
    status = models.IntegerField(default=0, verbose_name="菜单状态")
    
    type = models.CharField(max_length=10, verbose_name="菜单类型")

    '''links = models.BooleanField(
        choices=([0, "否"], [1, "是"]), default=0, verbose_name="是否外链"
    )
    cache = models.BooleanField(
        choices=([0, "否"], [1, "是"]), default=1, verbose_name="是否缓存"
    )
    visible = models.BooleanField(
        choices=([0, "否"], [1, "是"]), default=1, verbose_name="是否可见"
    )
    status = models.BooleanField(
        choices=([0, "正常"], [1, "禁用"], [2, "删除"]), default=0, verbose_name="菜单状态"
    )'''

    perms = models.CharField(max_length=200, verbose_name="权限")
    icon = models.CharField(max_length=200, verbose_name="图标")

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_menu'
        verbose_name = '菜单'
        verbose_name_plural = verbose_name  # 显示的复数名称
         

# 单位
class DeptModel(models.Model):
    
    name = models.CharField(max_length=50, verbose_name="单位名称")
    pid = models.IntegerField(default=0, verbose_name="pid")
    order_num = models.IntegerField(default=0, verbose_name="排序")
    type = models.CharField(max_length=10, verbose_name="单位类型")

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_dept'
        verbose_name = '单位'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    
# 角色
class RoleModel(models.Model):
    
    name = models.CharField(max_length=50, verbose_name="名称")
    order_num = models.IntegerField(default=0, verbose_name="排序")

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_role'
        verbose_name = '角色'
        verbose_name_plural = verbose_name  # 显示的复数名称
         

# 人员管理
class StaffModel(models.Model):
    name = models.CharField(max_length=50, verbose_name="名称")
    dept_id = models.CharField(max_length=50, verbose_name="dept_id")
    idcard = models.CharField(max_length=50, verbose_name="身份证")
    mobile = models.CharField(max_length=30, verbose_name="电话")
    address = models.CharField(max_length=250, verbose_name="地址")
    entry_time = models.DateTimeField(auto_now=False, verbose_name="入职时间")
    leave_time = models.DateTimeField(auto_now=False, verbose_name="离职时间")
    job = models.CharField(max_length=100, verbose_name="职位")

    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_staff'
        verbose_name = '人员'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 终端管理
class DeviceModel(models.Model):
    dept_id = models.CharField(max_length=50, verbose_name="dept_id")
    staff_id = models.CharField(max_length=50, verbose_name="staff_id")
    mac = models.CharField(max_length=50, verbose_name="mac")
    ip = models.CharField(max_length=50, verbose_name="ip")
    sys = models.CharField(max_length=50, verbose_name="操作系统")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    #check_detail=models.ManyToManyField(to="DeviceCheckModel",on_delete=models.CASCADE)

    class Meta:
        db_table = 'app_device'
        verbose_name = '终端管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
# 终端检查管理
class DeviceCheckModel(models.Model):
    device_id = models.IntegerField(default=0, verbose_name="device_id")
    mac_id = models.CharField(max_length=50, verbose_name="客户端ID")
    #device = models.ForeignKey(to='DeviceModel', to_field='id', related_name='app_device', on_delete=models.CASCADE, blank=True, null=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_device_check'
        verbose_name = '终端检查管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         

# 软件扫描结果
class DeviceSoftModel(models.Model):
    user_id = models.IntegerField(default=0, verbose_name="user_id")
    username = models.CharField(max_length=50, verbose_name="user_name")
    dept_id = models.CharField(max_length=50, verbose_name="dept_id")
    soft_name = models.CharField(max_length=50, verbose_name="soft_name")
    soft_version = models.CharField(max_length=50, verbose_name="softsoft_version_name")
    soft_type = models.CharField(max_length=50, verbose_name="soft_type")
    soft_time = models.DateTimeField(auto_now=True, verbose_name="soft_time")
    is_auth = models.CharField(max_length=50, verbose_name="is_auth")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_device_soft'
        verbose_name = '软件扫描结果'
        verbose_name_plural = verbose_name  # 显示的复数名称    

# 合同管理
class AgreementModel(models.Model):
    
    name = models.CharField(max_length=250, verbose_name="合同名称")
    no = models.CharField(max_length=50, verbose_name="合同编号")
    first_party = models.CharField(max_length=250, verbose_name="甲方")
    second_party = models.CharField(max_length=250, verbose_name="乙方")
    effective_time = models.DateTimeField(auto_now=False, verbose_name="生效时间")
    links = models.CharField(max_length=250, verbose_name="扫描件")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_agreement'
        verbose_name = '合同管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 授权管理
class AuthModel(models.Model):
    
    agreement_id = models.IntegerField(default=0, verbose_name="合同ID")
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    name = models.CharField(max_length=250, verbose_name="软件名称")
    type = models.CharField(max_length=50, verbose_name="授权类型")
    version = models.CharField(max_length=50, verbose_name="版本号")
    total = models.IntegerField(default=0, verbose_name="许可数")
    num = models.IntegerField(default=0, verbose_name="安装数")
    validity_time = models.DateTimeField(auto_now=False, verbose_name="有效时间")
    is_xc = models.IntegerField(default=0, verbose_name="是否国产")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_auth'
        verbose_name = '授权管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 领导小组
class LeaderModel(models.Model):
    
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    name = models.CharField(max_length=250, verbose_name="姓名")
    job = models.CharField(max_length=250, verbose_name="分工")
    title = models.CharField(max_length=250, verbose_name="职务")
    mobile = models.CharField(max_length=50, verbose_name="联系电话")
    phone = models.CharField(max_length=50, verbose_name="办公电话")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_leader'
        verbose_name = '领导小组'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 资产申请记录表
class ApplyModel(models.Model):
    
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    staff_id = models.IntegerField(default=0, verbose_name="staff_id")
    type = models.CharField(max_length=50, verbose_name="软件类型")
    purpose = models.CharField(max_length=50, verbose_name="软件用途")
    fun = models.CharField(max_length=50, verbose_name="软件功能")
    num = models.IntegerField(default=0, verbose_name="许可数")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_apply'
        verbose_name = '资产申请记录表'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 采购计划表
class PurchaseModel(models.Model):
    
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    staff_id = models.IntegerField(default=0, verbose_name="staff_id")
    type = models.CharField(max_length=50, verbose_name="软件类型")
    is_xc = models.IntegerField(default=0, verbose_name="是否国产")
    name = models.CharField(max_length=250, verbose_name="软件名称")
    version = models.CharField(max_length=50, verbose_name="版本号")
    num = models.IntegerField(default=0, verbose_name="许可数")
    validity_time = models.DateTimeField(auto_now=False, verbose_name="有效时间")
    price = models.IntegerField(default=0, verbose_name="单价")
    total = models.IntegerField(default=0, verbose_name="总价")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_purchase'
        verbose_name = '采购计划表'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 相关制度
class DutyModel(models.Model):
    
    name = models.CharField(max_length=250, verbose_name="制度名称")
    links = models.CharField(max_length=250, verbose_name="制度链接")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_duty'
        verbose_name = '相关制度'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 资产列表
class HardwareModel(models.Model):
    
    agreement_name = models.CharField(max_length=250, verbose_name="合同名称")
    agreement_time = models.DateTimeField(auto_now=False, verbose_name="采购日期")
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    brand = models.CharField(max_length=50, verbose_name="品牌")
    version = models.CharField(max_length=50, verbose_name="型号")
    device_id = models.CharField(max_length=50, verbose_name="客户端ID")
    ip = models.CharField(max_length=50, verbose_name="ip")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_hardware'
        verbose_name = '资产列表'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 采购管理
class HardwarePurchaseModel(models.Model):
    
    agreement_name = models.CharField(max_length=250, verbose_name="合同名称")
    supplier_name = models.CharField(max_length=250, verbose_name="供应商")
    username = models.CharField(max_length=50, verbose_name="经手人")
    agreement_time = models.DateTimeField(auto_now=False, verbose_name="采购日期")
    dept_id = models.IntegerField(default=0, verbose_name="dept_id")
    price = models.IntegerField(default=0, verbose_name="单价")
    num = models.IntegerField(default=0, verbose_name="数量")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_hardware_purchase'
        verbose_name = '采购管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
    

# 供应商管理
class SupplierModel(models.Model):
    
    name = models.CharField(max_length=250, verbose_name="供应商名称")
    username = models.CharField(max_length=50, verbose_name="联系人")
    mobile = models.CharField(max_length=50, verbose_name="联系电话")
    address = models.CharField(max_length=250, verbose_name="地址")
    join_time = models.DateTimeField(auto_now=False, verbose_name="加入时间")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'app_supplier'
        verbose_name = '供应商管理'
        verbose_name_plural = verbose_name  # 显示的复数名称
         
# 字典管理
class DictModel(models.Model):
    name = models.CharField(max_length=250, verbose_name="名称")
    type = models.CharField(max_length=50, verbose_name="关联字段")
    status = models.IntegerField(default=0, verbose_name="状态")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_dict'
        verbose_name = '字典管理'
        verbose_name_plural = verbose_name  # 显示的复数名称 
  
# 字典值管理
class DictDataModel(models.Model):
    value = models.IntegerField(default=0, verbose_name="值")
    label = models.CharField(max_length=250, verbose_name="名称")
    type = models.CharField(max_length=50, verbose_name="关联字段")
    status = models.IntegerField(default=0, verbose_name="状态")
    remarks = models.TextField(verbose_name="备注")
    create_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        db_table = 'sys_dict_data'
        verbose_name = '字典值管理'
        verbose_name_plural = verbose_name  # 显示的复数名称